home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / cc / sprite / toplev.c < prev   
Encoding:
C/C++ Source or Header  |  1990-08-21  |  52.2 KB  |  2,073 lines

  1. /* Top level of GNU C compiler
  2.    Copyright (C) 1987, 1988, 1989 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20.  
  21. /* This is the top level of cc1.
  22.    It parses command args, opens files, invokes the various passes
  23.    in the proper order, and counts the time used by each.
  24.    Error messages and low-level interface to malloc also handled here.  */
  25.  
  26. #include "config.h"
  27. #include <stdio.h>
  28. #include <signal.h>
  29. #include <setjmp.h>
  30.  
  31. #include <sys/types.h>
  32. #include <sys/stat.h>
  33.  
  34. #ifdef USG
  35. #undef FLOAT
  36. #include <sys/param.h>
  37. /* This is for hpux.  It is a real screw.  They should change hpux.  */
  38. #undef FLOAT
  39. #include <sys/times.h>
  40. #include <time.h>   /* Correct for hpux at least.  Is it good on other USG?  */
  41. #undef FFS  /* Some systems define this in param.h.  */
  42. #else
  43. #ifndef VMS
  44. #include <sys/time.h>
  45. #include <sys/resource.h>
  46. #endif
  47. #endif
  48.  
  49. #include "input.h"
  50. #include "tree.h"
  51. #include "c-tree.h"
  52. #include "rtl.h"
  53. #include "flags.h"
  54.  
  55. extern int yydebug;
  56.  
  57. extern FILE *finput;
  58.  
  59. extern int reload_completed;
  60. extern int rtx_equal_function_value_matters;
  61.  
  62. extern void init_lex ();
  63. extern void init_decl_processing ();
  64. extern void init_tree ();
  65. extern void init_rtl ();
  66. extern void init_optabs ();
  67. extern void init_reg_sets ();
  68. extern void dump_flow_info ();
  69. extern void dump_local_alloc ();
  70.  
  71. void rest_of_decl_compilation ();
  72. void error ();
  73. void error_with_file_and_line ();
  74. void fancy_abort ();
  75. void set_target_switch ();
  76. void print_target_switch_defaults ();
  77.  
  78. /* Bit flags that specify the machine subtype we are compiling for.
  79.    Bits are tested using macros TARGET_... defined in the tm-...h file
  80.    and set by `-m...' switches.  */
  81.  
  82. int target_flags;
  83.  
  84. /* Name of current original source file (what was input to cpp).
  85.    This comes from each #-command in the actual input.  */
  86.  
  87. char *input_filename;
  88.  
  89. /* Name of top-level original source file (what was input to cpp).
  90.    This comes from the #-command at the beginning of the actual input.
  91.    If there isn't any there, then this is the cc1 input file name.  */
  92.  
  93. char *main_input_filename;
  94.  
  95. /* Current line number in real source file.  */
  96.  
  97. int lineno;
  98.  
  99. /* Stack of currently pending input files.  */
  100.  
  101. struct file_stack *input_file_stack;
  102.  
  103. /* Incremented on each change to input_file_stack.  */
  104. int input_file_stack_tick;
  105.  
  106. /* FUNCTION_DECL for function now being parsed or compiled.  */
  107.  
  108. extern tree current_function_decl;
  109.  
  110. /* Name to use as base of names for dump output files.  */
  111.  
  112. char *dump_base_name;
  113.  
  114. /* Flags saying which kinds of debugging dump have been requested.  */
  115.  
  116. int rtl_dump = 0;
  117. int rtl_dump_and_exit = 0;
  118. int jump_opt_dump = 0;
  119. int cse_dump = 0;
  120. int loop_dump = 0;
  121. int flow_dump = 0;
  122. int combine_dump = 0;
  123. int local_reg_dump = 0;
  124. int global_reg_dump = 0;
  125. int jump2_opt_dump = 0;
  126. int dbr_sched_dump = 0;
  127.  
  128. /* 1 => write gdb debugging output (using symout.c).  -g
  129.    2 => write dbx debugging output (using dbxout.c).  -G
  130.    3 => write sdb debugging output (using sdbout.c).  -g.  */
  131.  
  132. enum debugger write_symbols = NO_DEBUG;
  133.  
  134. /* Nonzero means can use our own extensions to DBX format.
  135.    Relevant only with write_symbols == DBX_DEBUG.  */
  136.  
  137. int use_gdb_dbx_extensions;
  138.  
  139. /* Nonzero means do optimizations.  -opt.  */
  140.  
  141. int optimize = 0;
  142.  
  143. /* Nonzero means `char' should be signed.  */
  144.  
  145. int flag_signed_char;
  146.  
  147. /* Nonzero means give an enum type only as many bytes as it needs.  */
  148.  
  149. int flag_short_enums;
  150.  
  151. /* Nonzero for -fcaller-saves: allocate values in regs that need to
  152.    be saved across function calls, if that produces overall better code.
  153.    Optional now, so people can test it.  */
  154.  
  155. #ifdef DEFAULT_CALLER_SAVES
  156. int flag_caller_saves = 1;
  157. #else
  158. int flag_caller_saves = 0;
  159. #endif
  160.  
  161. /* Nonzero for -fpcc-struct-return: return values the same way PCC does.  */
  162.  
  163. int flag_pcc_struct_return = 0;
  164.  
  165. /* Nonzero for -fforce-mem: load memory value into a register
  166.    before arithmetic on it.  This makes better cse but slower compilation.  */
  167.  
  168. int flag_force_mem = 0;
  169.  
  170. /* Nonzero for -fforce-addr: load memory address into a register before
  171.    reference to memory.  This makes better cse but slower compilation.  */
  172.  
  173. int flag_force_addr = 0;
  174.  
  175. /* Nonzero for -fdefer-pop: don't pop args after each function call;
  176.    instead save them up to pop many calls' args with one insns.  */
  177.  
  178. int flag_defer_pop = 1;
  179.  
  180. /* Nonzero for -ffloat-store: don't allocate floats and doubles
  181.    in extended-precision registers.  */
  182.  
  183. int flag_float_store = 0;
  184.  
  185. /* Nonzero for -fcombine-regs:
  186.    allow instruction combiner to combine an insn
  187.    that just copies one reg to another.  */
  188.  
  189. int flag_combine_regs = 0;
  190.  
  191. /* Nonzero enables strength-reduction in loop.c.  */
  192.  
  193. int flag_strength_reduce = 0;
  194.  
  195. /* Nonzero for -fwritable-strings:
  196.    store string constants in data segment and don't uniquize them.  */
  197.  
  198. int flag_writable_strings = 0;
  199.  
  200. /* Nonzero means don't put addresses of constant functions in registers.
  201.    Used for compiling the Unix kernel, where strange substitutions are
  202.    done on the assembly output.  */
  203.  
  204. int flag_no_function_cse = 0;
  205.  
  206. /* Nonzero for -fomit-frame-pointer:
  207.    don't make a frame pointer in simple functions that don't require one.  */
  208.  
  209. int flag_omit_frame_pointer = 0;
  210.  
  211. /* Nonzero to inhibit use of define_optimization peephole opts.  */
  212.  
  213. int flag_no_peephole = 0;
  214.  
  215. /* Nonzero means all references through pointers are volatile.  */
  216.  
  217. int flag_volatile;
  218.  
  219. /* Nonzero means just do syntax checking; don't output anything.  */
  220.  
  221. int flag_syntax_only = 0;
  222.  
  223. /* Nonzero means do stupid register allocation.  -noreg.
  224.    This and `optimize' are controlled by different switches in cc1,
  225.    but normally cc controls them both with the -O switch.  */
  226.  
  227. int obey_regdecls = 0;
  228.  
  229. /* Don't print functions as they are compiled and don't print
  230.    times taken by the various passes.  -quiet.  */
  231.  
  232. int quiet_flag = 0;
  233.  
  234. /* Don't print warning messages.  -w.  */
  235.  
  236. int inhibit_warnings = 0;
  237.  
  238. /* Do print extra warnings (such as for uninitialized variables).  -W.  */
  239.  
  240. int extra_warnings = 0;
  241.  
  242. /* Nonzero to warn about unused local variables.  */
  243.  
  244. int warn_unused;
  245.  
  246. /* Nonzero means warn about all declarations which shadow others.   */
  247.  
  248. int warn_shadow;
  249.  
  250. /* Warn if a switch on an enum fails to have a case for every enum value.  */
  251.  
  252. int warn_switch;
  253.  
  254. /* Nonzero means warn about any identifiers that match in the first N
  255.    characters.  The value N is in `id_clash_len'.  */
  256.  
  257. int warn_id_clash;
  258. int id_clash_len;
  259.  
  260. /* Number of error messages and warning messages so far.  */
  261.  
  262. int errorcount = 0;
  263. int warningcount = 0;
  264. int sorrycount = 0;
  265.  
  266. /* Name of program invoked, sans directories.  */
  267.  
  268. char *progname;
  269.  
  270. /* Nonzero if generating code to do profiling.  */
  271.  
  272. int profile_flag = 0;
  273.  
  274. /* Nonzero if generating code to do profiling on a line-by-line basis.  */
  275.  
  276. int profile_block_flag;
  277.  
  278. /* Nonzero for -pedantic switch: warn about anything
  279.    that standard spec forbids.  */
  280.  
  281. int pedantic = 0;
  282.  
  283. /* Nonzero for -finline-functions: ok to inline functions that look like
  284.    good inline candidates.  */
  285.  
  286. int flag_inline_functions;
  287.  
  288. /* Nonzero for -fkeep-inline-functions: even if we make a function
  289.    go inline everywhere, keep its defintion around for debugging
  290.    purposes.  */
  291.  
  292. int flag_keep_inline_functions;
  293.  
  294. /* Nonzero means make the text shared if supported.  */
  295.  
  296. int flag_shared_data;
  297.  
  298. /* Nonzero means schedule into delayed branch slots if supported.  */
  299.  
  300. int flag_delayed_branch;
  301.  
  302. /* Copy of arguments to main.  */
  303. int save_argc;
  304. char **save_argv;
  305.  
  306. /* Name for output file of assembly code, specified with -o.  */
  307.  
  308. char *asm_file_name;
  309.  
  310. /* Name for output file of GDB symbol segment, specified with -symout.  */
  311.  
  312. char *sym_file_name;
  313.  
  314. /* Table of language-independent -f options.
  315.    STRING is the option name.  VARIABLE is the address of the variable.
  316.    ON_VALUE is the value to store in VARIABLE
  317.     if `-fSTRING' is seen as an option.
  318.    (If `-fno-STRING' is seen as an option, the opposite value is stored.)  */
  319.  
  320. struct { char *string; int *variable; int on_value;} f_options[] =
  321. {
  322.   {"float-store", &flag_float_store, 1},
  323.   {"volatile", &flag_volatile, 1},
  324.   {"defer-pop", &flag_defer_pop, 1},
  325.   {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
  326.   {"strength-reduce", &flag_strength_reduce, 1},
  327.   {"writable-strings", &flag_writable_strings, 1},
  328.   {"peephole", &flag_no_peephole, 0},
  329.   {"force-mem", &flag_force_mem, 1},
  330.   {"force-addr", &flag_force_addr, 1},
  331.   {"combine-regs", &flag_combine_regs, 1},
  332.   {"function-cse", &flag_no_function_cse, 0},
  333.   {"inline-functions", &flag_inline_functions, 1},
  334.   {"keep-inline-functions", &flag_keep_inline_functions, 1},
  335.   {"syntax-only", &flag_syntax_only, 1},
  336.   {"shared-data", &flag_shared_data, 1},
  337.   {"caller-saves", &flag_caller_saves, 1},
  338.   {"pcc-struct-return", &flag_pcc_struct_return, 1},
  339.   {"delayed-branch", &flag_delayed_branch, 1}
  340. };
  341.  
  342. /* Output files for assembler code (real compiler output)
  343.    and debugging dumps.  */
  344.  
  345. FILE *asm_out_file;
  346. FILE *rtl_dump_file;
  347. FILE *jump_opt_dump_file;
  348. FILE *cse_dump_file;
  349. FILE *loop_dump_file;
  350. FILE *flow_dump_file;
  351. FILE *combine_dump_file;
  352. FILE *local_reg_dump_file;
  353. FILE *global_reg_dump_file;
  354. FILE *jump2_opt_dump_file;
  355. FILE *dbr_sched_dump_file;
  356.  
  357. /* Time accumulators, to count the total time spent in various passes.  */
  358.  
  359. int parse_time;
  360. int varconst_time;
  361. int integration_time;
  362. int jump_time;
  363. int cse_time;
  364. int loop_time;
  365. int flow_time;
  366. int combine_time;
  367. int local_alloc_time;
  368. int global_alloc_time;
  369. int dbr_sched_time;
  370. int final_time;
  371. int symout_time;
  372. int dump_time;
  373.  
  374. /* Return time used so far, in microseconds.  */
  375.  
  376. int
  377. gettime ()
  378. {
  379. #ifdef USG
  380.   struct tms tms;
  381. #else
  382. #ifndef VMS
  383.   struct rusage rusage;
  384. #else /* VMS */
  385.   struct
  386.     {
  387.       int proc_user_time;
  388.       int proc_system_time;
  389.       int child_user_time;
  390.       int child_system_time;
  391.     } vms_times;
  392. #endif
  393. #endif
  394.  
  395.   if (quiet_flag)
  396.     return 0;
  397.  
  398. #ifdef USG
  399.   times (&tms);
  400.   return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
  401. #else
  402. #ifndef VMS
  403.   getrusage (0, &rusage);
  404.   return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
  405.       + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
  406. #else /* VMS */
  407.   times (&vms_times);
  408.   return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
  409. #endif
  410. #endif
  411. }
  412.  
  413. #define TIMEVAR(VAR, BODY)    \
  414. do { int otime = gettime (); BODY; VAR += gettime () - otime; } while (0)
  415.  
  416. void
  417. print_time (str, total)
  418.      char *str;
  419.      int total;
  420. {
  421.   fprintf (stderr,
  422.        "time in %s: %d.%06d\n",
  423.        str, total / 1000000, total % 1000000);
  424. }
  425.  
  426. /* Count an error or warning.  Return 1 if the message should be printed.  */
  427.  
  428. int
  429. count_error (warningp)
  430.      int warningp;
  431. {
  432.   if (warningp && inhibit_warnings)
  433.     return 0;
  434.  
  435.   if (warningp)
  436.     warningcount++;
  437.   else
  438.     errorcount++;
  439.  
  440.   return 1;
  441. }
  442.  
  443. /* Print a fatal error message.  NAME is the text.
  444.    Also include a system error message based on `errno'.  */
  445.  
  446. void
  447. pfatal_with_name (name)
  448.      char *name;
  449. {
  450.   fprintf (stderr, "%s: ", progname);
  451.   perror (name);
  452.   exit (35);
  453. }
  454.  
  455. void
  456. fatal_io_error (name)
  457.      char *name;
  458. {
  459.   fprintf (stderr, "%s: %s: I/O error\n", progname, name);
  460.   exit (35);
  461. }
  462.  
  463. void
  464. fatal (s, v)
  465.      char *s;
  466.      int v;
  467. {
  468.   error (s, v);
  469.   exit (34);
  470. }
  471.  
  472. /* Called from insn-extract to give a better error message when we
  473.    don't have an insn to match what we are looking for, rather
  474.    than just calling abort().  */
  475.  
  476. void
  477. fatal_insn_not_found (insn)
  478.      rtx insn;
  479. {
  480.   error ("The following insn was not recognizable:", 0);
  481.   debug_rtx (insn);
  482.   abort ();
  483. }
  484.  
  485. static int need_error_newline;
  486.  
  487. /* Function of last error message;
  488.    more generally, function such that if next error message is in it
  489.    then we don't have to mention the function name.  */
  490. static tree last_error_function = NULL;
  491.  
  492. /* Used to detect when input_file_stack has changed since last described.  */
  493. static int last_error_tick;
  494.  
  495. /* Called when the start of a function definition is parsed,
  496.    this function prints on stderr the name of the function.  */
  497.  
  498. void
  499. announce_function (decl)
  500.      tree decl;
  501. {
  502.   if (! quiet_flag)
  503.     {
  504.       fprintf (stderr, " %s", DECL_PRINT_NAME (decl));
  505.       fflush (stderr);
  506.       need_error_newline = 1;
  507.       last_error_function = current_function_decl;
  508.     }
  509. }
  510.  
  511. /* Prints out, if necessary, the name of the current function
  512.    which caused an error.  Called from all error and warning functions.  */
  513.  
  514. void
  515. report_error_function (file)
  516.      char *file;
  517. {
  518.   struct file_stack *p;
  519.  
  520.   if (need_error_newline)
  521.     {
  522.       fprintf (stderr, "\n");
  523.       need_error_newline = 0;
  524.     }
  525.  
  526.   if (last_error_function != current_function_decl)
  527.     {
  528.       if (file)
  529.     fprintf (stderr, "%s: ", file);
  530.  
  531.       if (current_function_decl == NULL)
  532.     fprintf (stderr, "At top level:\n");
  533.       else if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
  534.     fprintf (stderr, "In method %s:\n",
  535.          DECL_PRINT_NAME (current_function_decl));
  536.       else
  537.     fprintf (stderr, "In function %s:\n",
  538.          DECL_PRINT_NAME (current_function_decl));
  539.  
  540.       last_error_function = current_function_decl;
  541.     }
  542.   if (input_file_stack && input_file_stack->next != 0
  543.       && input_file_stack_tick != last_error_tick)
  544.     {
  545.       fprintf (stderr, "In file included");
  546.       for (p = input_file_stack->next; p; p = p->next)
  547.     {
  548.       fprintf (stderr, " from %s:%d", p->name, p->line);
  549.       if (p->next)
  550.         fprintf (stderr, ",");
  551.     }
  552.       fprintf (stderr, ":\n");
  553.       last_error_tick = input_file_stack_tick;
  554.     }
  555. }
  556.  
  557. /* Report an error at the current line number.
  558.    S and V are a string and an arg for `printf'.  */
  559.  
  560. void
  561. error (s, v, v2)
  562.      char *s;
  563.      int v;            /* @@also used as pointer */
  564.      int v2;            /* @@also used as pointer */
  565. {
  566.   error_with_file_and_line (input_filename, lineno, s, v, v2);
  567. }
  568.  
  569. /* Report an error at line LINE of file FILE.
  570.    S and V are a string and an arg for `printf'.  */
  571.  
  572. void
  573. error_with_file_and_line (file, line, s, v, v2)
  574.      char *file;
  575.      int line;
  576.      char *s;
  577.      int v;
  578.      int v2;
  579. {
  580.   count_error (0);
  581.  
  582.   report_error_function (file);
  583.  
  584.   if (file)
  585.     fprintf (stderr, "%s:%d: ", file, line);
  586.   else
  587.     fprintf (stderr, "%s: ", progname);
  588.   fprintf (stderr, s, v, v2);
  589.   fprintf (stderr, "\n");
  590. }
  591.  
  592. /* Report an error at the declaration DECL.
  593.    S and V are a string and an arg which uses %s to substitute the declaration name.  */
  594.  
  595. void
  596. error_with_decl (decl, s, v)
  597.      tree decl;
  598.      char *s;
  599.      int v;
  600. {
  601.   count_error (0);
  602.  
  603.   report_error_function (DECL_SOURCE_FILE (decl));
  604.  
  605.   fprintf (stderr, "%s:%d: ",
  606.        DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
  607.  
  608.   if (DECL_PRINT_NAME (decl))
  609.     fprintf (stderr, s, DECL_PRINT_NAME (decl), v);
  610.   else if (DECL_NAME (decl))
  611.     fprintf (stderr, s, IDENTIFIER_POINTER (DECL_NAME (decl)), v);
  612.   else
  613.     fprintf (stderr, s, "((anonymous))", v);
  614.   fprintf (stderr, "\n");
  615. }
  616.  
  617. /* Report an error at the line number of the insn INSN.
  618.    S and V are a string and an arg for `printf'.
  619.    This is used only when INSN is an `asm' with operands,
  620.    and each ASM_OPERANDS records its own source file and line.  */
  621.  
  622. void
  623. error_for_asm (insn, s, v, v2)
  624.      rtx insn;
  625.      char *s;
  626.      int v;            /* @@also used as pointer */
  627.      int v2;            /* @@also used as pointer */
  628. {
  629.   rtx temp;
  630.   char *filename;
  631.   int line;
  632.   rtx body = PATTERN (insn);
  633.   rtx asmop;
  634.  
  635.   /* Find the (or one of the) ASM_OPERANDS in the insn.  */
  636.   if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
  637.     asmop = SET_SRC (body);
  638.   else if (GET_CODE (body) == ASM_OPERANDS)
  639.     asmop = body;
  640.   else if (GET_CODE (body) == PARALLEL
  641.        && GET_CODE (XVECEXP (body, 0, 0)) == SET)
  642.     asmop = SET_SRC (XVECEXP (body, 0, 0));
  643.   else if (GET_CODE (body) == PARALLEL
  644.        && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
  645.     asmop = XVECEXP (body, 0, 0);
  646.  
  647.   filename = ASM_OPERANDS_SOURCE_FILE (asmop);
  648.   line = ASM_OPERANDS_SOURCE_LINE (asmop);
  649.  
  650.   error_with_file_and_line (filename, line, s, v, v2);
  651. }
  652.  
  653. /* Report a warning at line LINE.
  654.    S and V are a string and an arg for `printf'.  */
  655.  
  656. void
  657. warning_with_file_and_line (file, line, s, v, v2)
  658.      char *file;
  659.      int line;
  660.      char *s;
  661.      int v;
  662.      int v2;
  663. {
  664.   if (count_error (1) == 0)
  665.     return;
  666.  
  667.   report_error_function (file);
  668.  
  669.   if (file)
  670.     fprintf (stderr, "%s:%d: ", file, line);
  671.   else
  672.     fprintf (stderr, "%s: ", progname);
  673.  
  674.   fprintf (stderr, "warning: ");
  675.   fprintf (stderr, s, v, v2);
  676.   fprintf (stderr, "\n");
  677. }
  678.  
  679. /* Report a warning at the current line number.
  680.    S and V are a string and an arg for `printf'.  */
  681.  
  682. void
  683. warning (s, v, v2)
  684.      char *s;
  685.      int v;            /* @@also used as pointer */
  686.      int v2;
  687. {
  688.   warning_with_file_and_line (input_filename, lineno, s, v, v2);
  689. }
  690.  
  691. /* Report a warning at the declaration DECL.
  692.    S is string which uses %s to substitute the declaration name.
  693.    V is a second parameter that S can refer to.  */
  694.  
  695. void
  696. warning_with_decl (decl, s, v)
  697.      tree decl;
  698.      char *s;
  699.      int v;
  700. {
  701.   if (count_error (1) == 0)
  702.     return;
  703.  
  704.   report_error_function (DECL_SOURCE_FILE (decl));
  705.  
  706.   fprintf (stderr, "%s:%d: ",
  707.        DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
  708.  
  709.   fprintf (stderr, "warning: ");
  710.   if (DECL_PRINT_NAME (decl))
  711.     fprintf (stderr, s, DECL_PRINT_NAME (decl), v);
  712.   else if (DECL_NAME (decl))
  713.     fprintf (stderr, s, IDENTIFIER_POINTER (DECL_NAME (decl)), v);
  714.   else
  715.     fprintf (stderr, s, "((anonymous))", v);
  716.   fprintf (stderr, "\n");
  717. }
  718.  
  719. /* Apologize for not implementing some feature.
  720.    S, V, and V2 are a string and args for `printf'.  */
  721.  
  722. void
  723. sorry (s, v, v2)
  724.      char *s;
  725.      int v, v2;
  726. {
  727.   sorrycount++;
  728.   if (input_filename)
  729.     fprintf (stderr, "%s:%d: ", input_filename, lineno);
  730.   else
  731.     fprintf (stderr, "%s: ", progname);
  732.  
  733.   fprintf (stderr, "sorry, not implemented: ");
  734.   fprintf (stderr, s, v, v2);
  735.   fprintf (stderr, "\n");
  736. }
  737.  
  738. /* Apologize for not implementing some feature, then quit.
  739.    S, V, and V2 are a string and args for `printf'.  */
  740.  
  741. void
  742. really_sorry (s, v, v2)
  743.      char *s;
  744.      int v, v2;
  745. {
  746.   if (input_filename)
  747.     fprintf (stderr, "%s:%d: ", input_filename, lineno);
  748.   else
  749.     fprintf (stderr, "c++: ");
  750.  
  751.   fprintf (stderr, "sorry, not implemented: ");
  752.   fprintf (stderr, s, v, v2);
  753.   fatal (" (fatal)\n");
  754. }
  755.  
  756. /* More 'friendly' abort that prints the line and file.
  757.    config.h can #define abort fancy_abort if you like that sort of thing.  */
  758.  
  759. void
  760. fancy_abort ()
  761. {
  762.   fatal ("Internal gcc abort.");
  763. }
  764.  
  765. /* When `malloc.c' is compiled with `rcheck' defined,
  766.    it calls this function to report clobberage.  */
  767.  
  768. void
  769. botch (s)
  770. {
  771.   abort ();
  772. }
  773.  
  774. /* Same as `malloc' but report error if no memory available.  */
  775.  
  776. int
  777. xmalloc (size)
  778.      unsigned size;
  779. {
  780.   register int value = (int) malloc (size);
  781.   if (value == 0)
  782.     fatal ("Virtual memory exhausted.");
  783.   return value;
  784. }
  785.  
  786. /* Same as `realloc' but report error if no memory available.  */
  787.  
  788. int
  789. xrealloc (ptr, size)
  790.      char *ptr;
  791.      int size;
  792. {
  793.   int result = realloc (ptr, size);
  794.   if (!result)
  795.     fatal ("Virtual memory exhausted.");
  796.   return result;
  797. }
  798.  
  799. /* Return the logarithm of X, base 2, considering X unsigned,
  800.    if X is a power of 2.  Otherwise, returns -1.  */
  801.  
  802. int
  803. exact_log2 (x)
  804.      register unsigned int x;
  805. {
  806.   register int log = 0;
  807.   for (log = 0; log < HOST_BITS_PER_INT; log++)
  808.     if (x == (1 << log))
  809.       return log;
  810.   return -1;
  811. }
  812.  
  813. /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
  814.    If X is 0, return -1.  */
  815.  
  816. int
  817. floor_log2 (x)
  818.      register unsigned int x;
  819. {
  820.   register int log = 0;
  821.   for (log = 0; log < HOST_BITS_PER_INT; log++)
  822.     if ((x & ((-1) << log)) == 0)
  823.       return log - 1;
  824.   return HOST_BITS_PER_INT - 1;
  825. }
  826.  
  827. int float_handled;
  828. jmp_buf float_handler;
  829.  
  830. /* Specify where to longjmp to when a floating arithmetic error happens.
  831.    If HANDLER is 0, it means don't handle the errors any more.  */
  832.  
  833. void
  834. set_float_handler (handler)
  835.      jmp_buf handler;
  836. {
  837.   float_handled = (handler != 0);
  838.   if (handler)
  839.     bcopy (handler, float_handler, sizeof (float_handler));
  840. }
  841.  
  842. /* Signals actually come here.  */
  843.  
  844. static void
  845. float_signal ()
  846. {
  847.   if (float_handled == 0)
  848.     abort ();
  849.   float_handled = 0;
  850.   longjmp (float_handler, 1);
  851. }
  852.  
  853. /* Handler for SIGPIPE.  */
  854.  
  855. static void
  856. pipe_closed ()
  857. {
  858.   fatal ("output pipe has been closed");
  859. }
  860.  
  861. /* Compile an entire file of output from cpp, named NAME.
  862.    Write a file of assembly output and various debugging dumps.  */
  863.  
  864. static void
  865. compile_file (name)
  866.      char *name;
  867. {
  868.   tree globals;
  869.   int start_time;
  870.   int dump_base_name_length;
  871.  
  872.   int name_specified = name != 0;
  873.  
  874.   if (dump_base_name == 0)
  875.     dump_base_name = name ? name : "gccdump";
  876.   dump_base_name_length = strlen (dump_base_name);
  877.  
  878.   parse_time = 0;
  879.   varconst_time = 0;
  880.   integration_time = 0;
  881.   jump_time = 0;
  882.   cse_time = 0;
  883.   loop_time = 0;
  884.   flow_time = 0;
  885.   combine_time = 0;
  886.   local_alloc_time = 0;
  887.   global_alloc_time = 0;
  888.   dbr_sched_time = 0;
  889.   final_time = 0;
  890.   symout_time = 0;
  891.   dump_time = 0;
  892.  
  893.   /* Open input file.  */
  894.  
  895.   if (name == 0 || !strcmp (name, "-"))
  896.     {
  897.       finput = stdin;
  898.       name = "stdin";
  899.     }
  900.   else
  901.     finput = fopen (name, "r");
  902.   if (finput == 0)
  903.     pfatal_with_name (name);
  904.  
  905.   /* Initialize data in various passes.  */
  906.  
  907.   init_tree ();
  908.   init_lex ();
  909.   init_rtl ();
  910.   init_emit_once ();
  911.   init_decl_processing ();
  912.   init_optabs ();
  913.  
  914.   /* If rtl dump desired, open the output file.  */
  915.   if (rtl_dump)
  916.     {
  917.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  918.       strcpy (dumpname, dump_base_name);
  919.       strcat (dumpname, ".rtl");
  920.       rtl_dump_file = fopen (dumpname, "w");
  921.       if (rtl_dump_file == 0)
  922.     pfatal_with_name (dumpname);
  923.     }
  924.  
  925.   /* If jump_opt dump desired, open the output file.  */
  926.   if (jump_opt_dump)
  927.     {
  928.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  929.       strcpy (dumpname, dump_base_name);
  930.       strcat (dumpname, ".jump");
  931.       jump_opt_dump_file = fopen (dumpname, "w");
  932.       if (jump_opt_dump_file == 0)
  933.     pfatal_with_name (dumpname);
  934.     }
  935.  
  936.   /* If cse dump desired, open the output file.  */
  937.   if (cse_dump)
  938.     {
  939.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  940.       strcpy (dumpname, dump_base_name);
  941.       strcat (dumpname, ".cse");
  942.       cse_dump_file = fopen (dumpname, "w");
  943.       if (cse_dump_file == 0)
  944.     pfatal_with_name (dumpname);
  945.     }
  946.  
  947.   /* If loop dump desired, open the output file.  */
  948.   if (loop_dump)
  949.     {
  950.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  951.       strcpy (dumpname, dump_base_name);
  952.       strcat (dumpname, ".loop");
  953.       loop_dump_file = fopen (dumpname, "w");
  954.       if (loop_dump_file == 0)
  955.     pfatal_with_name (dumpname);
  956.     }
  957.  
  958.   /* If flow dump desired, open the output file.  */
  959.   if (flow_dump)
  960.     {
  961.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  962.       strcpy (dumpname, dump_base_name);
  963.       strcat (dumpname, ".flow");
  964.       flow_dump_file = fopen (dumpname, "w");
  965.       if (flow_dump_file == 0)
  966.     pfatal_with_name (dumpname);
  967.     }
  968.  
  969.   /* If combine dump desired, open the output file.  */
  970.   if (combine_dump)
  971.     {
  972.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
  973.       strcpy (dumpname, dump_base_name);
  974.       strcat (dumpname, ".combine");
  975.       combine_dump_file = fopen (dumpname, "w");
  976.       if (combine_dump_file == 0)
  977.     pfatal_with_name (dumpname);
  978.     }
  979.  
  980.   /* If local_reg dump desired, open the output file.  */
  981.   if (local_reg_dump)
  982.     {
  983.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  984.       strcpy (dumpname, dump_base_name);
  985.       strcat (dumpname, ".lreg");
  986.       local_reg_dump_file = fopen (dumpname, "w");
  987.       if (local_reg_dump_file == 0)
  988.     pfatal_with_name (dumpname);
  989.     }
  990.  
  991.   /* If global_reg dump desired, open the output file.  */
  992.   if (global_reg_dump)
  993.     {
  994.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  995.       strcpy (dumpname, dump_base_name);
  996.       strcat (dumpname, ".greg");
  997.       global_reg_dump_file = fopen (dumpname, "w");
  998.       if (global_reg_dump_file == 0)
  999.     pfatal_with_name (dumpname);
  1000.     }
  1001.  
  1002.   /* If jump2_opt dump desired, open the output file.  */
  1003.   if (jump2_opt_dump)
  1004.     {
  1005.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
  1006.       strcpy (dumpname, dump_base_name);
  1007.       strcat (dumpname, ".jump2");
  1008.       jump2_opt_dump_file = fopen (dumpname, "w");
  1009.       if (jump2_opt_dump_file == 0)
  1010.     pfatal_with_name (dumpname);
  1011.     }
  1012.  
  1013.   /* If dbr_sched dump desired, open the output file.  */
  1014.   if (dbr_sched_dump)
  1015.     {
  1016.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
  1017.       strcpy (dumpname, dump_base_name);
  1018.       strcat (dumpname, ".dbr");
  1019.       dbr_sched_dump_file = fopen (dumpname, "w");
  1020.       if (dbr_sched_dump_file == 0)
  1021.     pfatal_with_name (dumpname);
  1022.     }
  1023.  
  1024.   /* Open assembler code output file.  */
  1025.  
  1026.   if (! name_specified && asm_file_name == 0)
  1027.     asm_out_file = stdout;
  1028.   else
  1029.     {
  1030.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1031.       int len = strlen (dump_base_name);
  1032.       strcpy (dumpname, dump_base_name);
  1033.       if (len > 2 && ! strcmp (".c", dumpname + len - 2))
  1034.     dumpname[len - 2] = 0;
  1035.       else if (len > 2 && ! strcmp (".i", dumpname + len - 2))
  1036.     dumpname[len - 2] = 0;
  1037.       else if (len > 3 && ! strcmp (".co", dumpname + len - 3))
  1038.     dumpname[len - 3] = 0;
  1039.       strcat (dumpname, ".s");
  1040.       if (asm_file_name == 0)
  1041.     {
  1042.       asm_file_name = (char *) malloc (strlen (dumpname) + 1);
  1043.       strcpy (asm_file_name, dumpname);
  1044.     }
  1045.       if (!strcmp (asm_file_name, "-"))
  1046.     asm_out_file = stdout;
  1047.       else
  1048.     asm_out_file = fopen (asm_file_name, "w");
  1049.       if (asm_out_file == 0)
  1050.     pfatal_with_name (asm_file_name);
  1051.     }
  1052.  
  1053.   input_filename = name;
  1054.  
  1055.   /* the beginning of the file is a new line; check for # */
  1056.   /* With luck, we discover the real source file's name from that
  1057.      and put it in input_filename.  */
  1058.   ungetc (check_newline (), finput);
  1059.  
  1060.   /* If the input doesn't start with a #line, use the input name
  1061.      as the official input file name.  */
  1062.   if (main_input_filename == 0)
  1063.     main_input_filename = name;
  1064.  
  1065.   /* Put an entry on the input file stack for the main input file.  */
  1066.   input_file_stack
  1067.     = (struct file_stack *) xmalloc (sizeof (struct file_stack));
  1068.   input_file_stack->next = 0;
  1069.   input_file_stack->name = input_filename;
  1070.  
  1071.   ASM_FILE_START (asm_out_file);
  1072.  
  1073.   /* Output something to inform GDB that this compilation was by GCC.  */
  1074. #ifndef ASM_IDENTIFY_GCC
  1075.   fprintf (asm_out_file, "gcc_compiled.:\n");
  1076. #else
  1077.   ASM_IDENTIFY_GCC (asm_out_file);
  1078. #endif
  1079.  
  1080.   /* If GDB symbol table desired, open the GDB symbol output file.  */
  1081.   if (write_symbols == GDB_DEBUG)
  1082.     {
  1083.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  1084.       int len = strlen (dump_base_name);
  1085.       strcpy (dumpname, dump_base_name);
  1086.       if (len > 2 && ! strcmp (".c", dumpname + len - 2))
  1087.     dumpname[len - 2] = 0;
  1088.       else if (len > 2 && ! strcmp (".i", dumpname + len - 2))
  1089.     dumpname[len - 2] = 0;
  1090.       else if (len > 3 && ! strcmp (".co", dumpname + len - 3))
  1091.     dumpname[len - 3] = 0;
  1092.       strcat (dumpname, ".sym");
  1093.       if (sym_file_name == 0)
  1094.     sym_file_name = dumpname;
  1095.       symout_init (sym_file_name, asm_out_file, main_input_filename);
  1096.     }
  1097.  
  1098.   /* If dbx symbol table desired, initialize writing it
  1099.      and output the predefined types.  */
  1100. #ifdef DBX_DEBUGGING_INFO
  1101.   if (write_symbols == DBX_DEBUG)
  1102.     dbxout_init (asm_out_file, main_input_filename);
  1103. #endif
  1104. #ifdef SDB_DEBUGGING_INFO
  1105.   if (write_symbols == SDB_DEBUG)
  1106.     sdbout_init (asm_out_file, main_input_filename);
  1107. #endif
  1108.  
  1109.   /* Initialize yet another pass.  */
  1110.  
  1111.   init_final (main_input_filename);
  1112.  
  1113.   start_time = gettime ();
  1114.  
  1115.   /* Call the parser, which parses the entire file
  1116.      (calling rest_of_compilation for each function).  */
  1117.  
  1118.   yyparse ();
  1119.  
  1120.   /* Compilation is now finished except for writing
  1121.      what's left of the symbol table output.  */
  1122.  
  1123.   parse_time += gettime () - start_time;
  1124.  
  1125.   parse_time -= integration_time;
  1126.   parse_time -= varconst_time;
  1127.  
  1128.   globals = getdecls ();
  1129.  
  1130.   /* Really define vars that have had only a tentative definition.
  1131.      Really output inline functions that must actually be callable
  1132.      and have not been output so far.  */
  1133.  
  1134.   {
  1135.     tree decl;
  1136.     for (decl = globals; decl; decl = TREE_CHAIN (decl))
  1137.       {
  1138.     if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
  1139.         && ! TREE_ASM_WRITTEN (decl))
  1140.       {
  1141.         /* Don't write out static consts, unless we needed
  1142.            to take their address for some reason.  */
  1143.         if (! TREE_READONLY (decl)
  1144.         || TREE_PUBLIC (decl)
  1145.         || TREE_ADDRESSABLE (decl))
  1146.           rest_of_decl_compilation (decl, 0, 1, 1);
  1147.         /* Otherwise maybe mention them just for the debugger.  */
  1148. #ifdef DBX_DEBUGGING_INFO
  1149.         else if (DECL_INITIAL (decl) && write_symbols == DBX_DEBUG)
  1150.           TIMEVAR (varconst_time, dbxout_symbol (decl, 0));
  1151. #endif
  1152. #ifdef SDB_DEBUGGING_INFO
  1153.         else if (DECL_INITIAL (decl) && write_symbols == SDB_DEBUG)
  1154.           TIMEVAR (varconst_time, sdbout_symbol (decl, 0));
  1155. #endif
  1156.       }
  1157.     if (TREE_CODE (decl) == FUNCTION_DECL
  1158.         && ! TREE_ASM_WRITTEN (decl)
  1159.         && DECL_INITIAL (decl) != 0
  1160.         && TREE_ADDRESSABLE (decl)
  1161.         && ! TREE_EXTERNAL (decl))
  1162.       output_inline_function (decl);
  1163.  
  1164.     /* Warn about any function declared static but not defined.  */
  1165.     if (warn_unused
  1166.         && TREE_CODE (decl) == FUNCTION_DECL
  1167.         && DECL_INITIAL (decl) == 0
  1168.         && TREE_EXTERNAL (decl)
  1169.         && ! TREE_PUBLIC (decl))
  1170.       warning_with_decl (decl, "`%s' declared but never defined");
  1171.     /* Warn about statics fns or vars defined but not used,
  1172.        but not about inline functions
  1173.        since unused inline statics is normal practice.  */
  1174.     if (warn_unused
  1175.         && (TREE_CODE (decl) == FUNCTION_DECL
  1176.         || TREE_CODE (decl) == VAR_DECL)
  1177.         && ! TREE_EXTERNAL (decl)
  1178.         && ! TREE_PUBLIC (decl)
  1179.         && ! TREE_USED (decl)
  1180.         && ! TREE_INLINE (decl)
  1181.         /* The TREE_USED bit for file-scope decls
  1182.            is kept in the identifier, to handle multiple
  1183.            external decls in different scopes.  */
  1184.         && ! TREE_USED (DECL_NAME (decl)))
  1185.         /* Ignore any unused static variable named `rcsid' so we
  1186.            don't get zillions of complaints. */
  1187.         if (! DECL_PRINT_NAME (decl)
  1188.         || strcmp(DECL_PRINT_NAME(decl), "rcsid")) {
  1189.             warning_with_decl (decl, "`%s' defined but not used");
  1190.         }
  1191.       }
  1192.   }
  1193.  
  1194.   /* Do dbx symbols */
  1195. #ifdef DBX_DEBUGGING_INFO
  1196.   if (write_symbols == DBX_DEBUG)
  1197.     TIMEVAR (symout_time,
  1198.          {
  1199.            dbxout_tags (gettags ());
  1200.            dbxout_types (get_permanent_types ());
  1201.          });
  1202. #endif
  1203.  
  1204. #ifdef SDB_DEBUGGING_INFO
  1205.   if (write_symbols == SDB_DEBUG)
  1206.     TIMEVAR (symout_time,
  1207.          {
  1208.            sdbout_tags (gettags ());
  1209.            sdbout_types (get_permanent_types ());
  1210.          });
  1211. #endif
  1212.  
  1213.   /* Do gdb symbols */
  1214.   if (write_symbols == GDB_DEBUG)
  1215.     TIMEVAR (symout_time,
  1216.          {
  1217.            struct stat statbuf;
  1218.            fstat (fileno (finput), &statbuf);
  1219.            symout_types (get_permanent_types ());
  1220.            symout_top_blocks (globals, gettags ());
  1221.            symout_finish (name, statbuf.st_ctime);
  1222.          });
  1223.  
  1224.   /* Output some stuff at end of file if nec.  */
  1225.  
  1226.   end_final (main_input_filename);
  1227.  
  1228. #ifdef ASM_FILE_END
  1229.   ASM_FILE_END (asm_out_file);
  1230. #endif
  1231.  
  1232.   /* Close the dump files.  */
  1233.  
  1234.   if (rtl_dump)
  1235.     fclose (rtl_dump_file);
  1236.  
  1237.   if (jump_opt_dump)
  1238.     fclose (jump_opt_dump_file);
  1239.  
  1240.   if (cse_dump)
  1241.     fclose (cse_dump_file);
  1242.  
  1243.   if (loop_dump)
  1244.     fclose (loop_dump_file);
  1245.  
  1246.   if (flow_dump)
  1247.     fclose (flow_dump_file);
  1248.  
  1249.   if (combine_dump)
  1250.     {
  1251.       dump_combine_total_stats (combine_dump_file);
  1252.       fclose (combine_dump_file);
  1253.     }
  1254.  
  1255.   if (local_reg_dump)
  1256.     fclose (local_reg_dump_file);
  1257.  
  1258.   if (global_reg_dump)
  1259.     fclose (global_reg_dump_file);
  1260.  
  1261.   if (jump2_opt_dump)
  1262.     fclose (jump2_opt_dump_file);
  1263.  
  1264.   if (dbr_sched_dump)
  1265.     fclose (dbr_sched_dump_file);
  1266.  
  1267.   /* Close non-debugging input and output files.  Take special care to note
  1268.      whether fclose returns an error, since the pages might still be on the
  1269.      buffer chain while the file is open.  */
  1270.  
  1271.   fclose (finput);
  1272.   if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)
  1273.     fatal_io_error (asm_file_name);
  1274.  
  1275.   /* Print the times.  */
  1276.  
  1277.   if (! quiet_flag)
  1278.     {
  1279.       fprintf (stderr,"\n");
  1280.       print_time ("parse", parse_time);
  1281.       print_time ("integration", integration_time);
  1282.       print_time ("jump", jump_time);
  1283.       print_time ("cse", cse_time);
  1284.       print_time ("loop", loop_time);
  1285.       print_time ("flow", flow_time);
  1286.       print_time ("combine", combine_time);
  1287.       print_time ("local-alloc", local_alloc_time);
  1288.       print_time ("global-alloc", global_alloc_time);
  1289.       print_time ("dbranch", dbr_sched_time);
  1290.       print_time ("final", final_time);
  1291.       print_time ("varconst", varconst_time);
  1292.       print_time ("symout", symout_time);
  1293.       print_time ("dump", dump_time);
  1294.     }
  1295. }
  1296.  
  1297. /* This is called from finish_decl (within yyparse)
  1298.    for each declaration of a function or variable.
  1299.    This does nothing for automatic variables.
  1300.    Otherwise, it sets up the RTL and outputs any assembler code
  1301.    (label definition, storage allocation and initialization).
  1302.  
  1303.    DECL is the declaration.  If ASMSPEC is nonzero, it specifies
  1304.    the assembler symbol name to be used.  TOP_LEVEL is nonzero
  1305.    if this declaration is not within a function.  */
  1306.  
  1307. void
  1308. rest_of_decl_compilation (decl, asmspec, top_level, at_end)
  1309.      tree decl;
  1310.      char *asmspec;
  1311.      int top_level;
  1312.      int at_end;
  1313. {
  1314.   /* Declarations of variables, and of functions defined elsewhere.  */
  1315.  
  1316.   if (TREE_STATIC (decl) || TREE_EXTERNAL (decl))
  1317.     TIMEVAR (varconst_time,
  1318.          {
  1319.            make_decl_rtl (decl, asmspec, top_level);
  1320.            /* Don't output anything
  1321.           when a tentative file-scope definition is seen.
  1322.           But at end of compilation, do output code for them.  */
  1323.            if (! (! at_end && top_level
  1324.               && (DECL_INITIAL (decl) == 0
  1325.               || DECL_INITIAL (decl) == error_mark_node)))
  1326.          assemble_variable (decl, top_level, write_symbols, at_end);
  1327.          });
  1328.   else if (TREE_REGDECL (decl) && asmspec != 0)
  1329.     {
  1330.       if (decode_reg_name (asmspec) >= 0)
  1331.     {
  1332.       DECL_RTL (decl) = 0;
  1333.       make_decl_rtl (decl, asmspec, top_level);
  1334.     }
  1335.       else
  1336.     error ("invalid register name `%s' for register variable", asmspec);
  1337.     }
  1338. #ifdef DBX_DEBUGGING_INFO
  1339.   else if (write_symbols == DBX_DEBUG && TREE_CODE (decl) == TYPE_DECL)
  1340.     TIMEVAR (varconst_time, dbxout_symbol (decl, 0));
  1341. #endif
  1342. #ifdef SDB_DEBUGGING_INFO
  1343.   else if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == TYPE_DECL)
  1344.     TIMEVAR (varconst_time, sdbout_symbol (decl, 0));
  1345. #endif
  1346.  
  1347.   if (top_level)
  1348.     {
  1349.       if (write_symbols == GDB_DEBUG)
  1350.     {
  1351.       TIMEVAR (symout_time,
  1352.            {
  1353.              /* The initizations make types when they contain
  1354.             string constants.  The types are on the temporary
  1355.             obstack, so output them now before they go away.  */
  1356.              symout_types (get_temporary_types ());
  1357.            });
  1358.     }
  1359.       else
  1360.     /* Clean out the temporary type list, since the types will go away.  */
  1361.     get_temporary_types ();
  1362.     }
  1363. }
  1364.  
  1365. /* This is called from finish_function (within yyparse)
  1366.    after each top-level definition is parsed.
  1367.    It is supposed to compile that function or variable
  1368.    and output the assembler code for it.
  1369.    After we return, the tree storage is freed.  */
  1370.  
  1371. void
  1372. rest_of_compilation (decl)
  1373.      tree decl;
  1374. {
  1375.   register rtx insns;
  1376.   int start_time = gettime ();
  1377.   int tem;
  1378.  
  1379.   /* If we are reconsidering an inline function
  1380.      at the end of compilation, skip the stuff for making it inline.  */
  1381.  
  1382.   if (DECL_SAVED_INSNS (decl) == 0)
  1383.     {
  1384.  
  1385.       /* If requested, consider whether to make this function inline.  */
  1386.       if (flag_inline_functions || TREE_INLINE (decl))
  1387.     {
  1388.       TIMEVAR (integration_time,
  1389.            {
  1390.              int specd = TREE_INLINE (decl);
  1391.              char *lose = function_cannot_inline_p (decl);
  1392.              if (lose != 0 && specd)
  1393.                warning_with_decl (decl, lose);
  1394.              if (lose == 0)
  1395.                save_for_inline (decl);
  1396.              else
  1397.                TREE_INLINE (decl) = 0;
  1398.            });
  1399.     }
  1400.  
  1401.       insns = get_insns ();
  1402.  
  1403.       /* Dump the rtl code if we are dumping rtl.  */
  1404.  
  1405.       if (rtl_dump)
  1406.     TIMEVAR (dump_time,
  1407.          {
  1408.            fprintf (rtl_dump_file, "\n;; Function %s\n\n",
  1409.                 IDENTIFIER_POINTER (DECL_NAME (decl)));
  1410.            if (DECL_SAVED_INSNS (decl))
  1411.              fprintf (rtl_dump_file, ";; (integrable)\n\n");
  1412.            print_rtl (rtl_dump_file, insns);
  1413.            fflush (rtl_dump_file);
  1414.          });
  1415.  
  1416.       /* If function is inline, and we don't yet know whether to
  1417.      compile it by itself, defer decision till end of compilation.
  1418.      finish_compilation will call rest_of_compilation again
  1419.      for those functions that need to be output.  */
  1420.  
  1421.       if (((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
  1422.         && ! flag_keep_inline_functions)
  1423.        || TREE_EXTERNAL (decl))
  1424.       && TREE_INLINE (decl))
  1425.     goto exit_rest_of_compilation;
  1426.     }
  1427.  
  1428.   if (rtl_dump_and_exit || flag_syntax_only)
  1429.     {
  1430.       get_temporary_types ();
  1431.       goto exit_rest_of_compilation;
  1432.     }
  1433.  
  1434.   TREE_ASM_WRITTEN (decl) = 1;
  1435.  
  1436.   insns = get_insns ();
  1437.  
  1438.   /* Copy any shared structure that should not be shared.  */
  1439.  
  1440.   unshare_all_rtl (insns);
  1441.  
  1442.   /* See if we have allocated stack slots that are not directly addressable.
  1443.      If so, scan all the insns and create explicit address computation
  1444.      for all references to such slots.  */
  1445. /*   fixup_stack_slots (); */
  1446.  
  1447.   /* Do jump optimization the first time, if -opt.
  1448.      Also do it if -W, but in that case it doesn't change the rtl code,
  1449.      it only computes whether control can drop off the end of the function.  */
  1450.  
  1451.   if (optimize || extra_warnings || warn_return_type
  1452.       /* If function is `volatile', we should warn if it tries to return.  */
  1453.       || TREE_THIS_VOLATILE (decl))
  1454.     TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
  1455.  
  1456.   /* Dump rtl code after jump, if we are doing that.  */
  1457.  
  1458.   if (jump_opt_dump)
  1459.     TIMEVAR (dump_time,
  1460.          {
  1461.            fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
  1462.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1463.            print_rtl (jump_opt_dump_file, insns);
  1464.            fflush (jump_opt_dump_file);
  1465.          });
  1466.  
  1467.   /* Perform common subexpression elimination.
  1468.      Nonzero value from `cse_main' means that jumps were simplified
  1469.      and some code may now be unreachable, so do
  1470.      jump optimization again.  */
  1471.  
  1472.   if (optimize)
  1473.     {
  1474.       TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 0));
  1475.  
  1476.       TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num ()));
  1477.  
  1478.       if (tem)
  1479.     TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
  1480.     }
  1481.  
  1482.   /* Dump rtl code after cse, if we are doing that.  */
  1483.  
  1484.   if (cse_dump)
  1485.     TIMEVAR (dump_time,
  1486.          {
  1487.            fprintf (cse_dump_file, "\n;; Function %s\n\n",
  1488.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1489.            print_rtl (cse_dump_file, insns);
  1490.            fflush (cse_dump_file);
  1491.          });
  1492.  
  1493.   if (loop_dump)
  1494.     TIMEVAR (dump_time,
  1495.          {
  1496.            fprintf (loop_dump_file, "\n;; Function %s\n\n",
  1497.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1498.          });
  1499.  
  1500.   /* Move constant computations out of loops.  */
  1501.  
  1502.   if (optimize)
  1503.     {
  1504.       TIMEVAR (loop_time,
  1505.            {
  1506.          reg_scan (insns, max_reg_num (), 1);
  1507.          loop_optimize (insns, loop_dump ? loop_dump_file : 0);
  1508.            });
  1509.     }
  1510.  
  1511.   /* Dump rtl code after loop opt, if we are doing that.  */
  1512.  
  1513.   if (loop_dump)
  1514.     TIMEVAR (dump_time,
  1515.          {
  1516.            print_rtl (loop_dump_file, insns);
  1517.            fflush (loop_dump_file);
  1518.          });
  1519.  
  1520.   /* Now we choose between stupid (pcc-like) register allocation
  1521.      (if we got the -noreg switch and not -opt)
  1522.      and smart register allocation.  */
  1523.  
  1524.   if (optimize)        /* Stupid allocation probably won't work */
  1525.     obey_regdecls = 0;    /* if optimizations being done.  */
  1526.  
  1527.   regclass_init ();
  1528.  
  1529.   /* Print function header into flow dump now
  1530.      because doing the flow analysis makes some of the dump.  */
  1531.  
  1532.   if (flow_dump)
  1533.     TIMEVAR (dump_time,
  1534.          {
  1535.            fprintf (flow_dump_file, "\n;; Function %s\n\n",
  1536.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1537.          });
  1538.  
  1539.   if (obey_regdecls)
  1540.     {
  1541.       TIMEVAR (flow_time,
  1542.            {
  1543.          regclass (insns, max_reg_num ());
  1544.          stupid_life_analysis (insns, max_reg_num (),
  1545.                        flow_dump_file);
  1546.            });
  1547.     }
  1548.   else
  1549.     {
  1550.       /* Do control and data flow analysis,
  1551.      and write some of the results to dump file.  */
  1552.  
  1553.       TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
  1554.                      flow_dump_file));
  1555.       if (extra_warnings)
  1556.     uninitialized_vars_warning (DECL_INITIAL (decl));
  1557.     }
  1558.  
  1559.   /* Dump rtl after flow analysis.  */
  1560.  
  1561.   if (flow_dump)
  1562.     TIMEVAR (dump_time,
  1563.          {
  1564.            print_rtl (flow_dump_file, insns);
  1565.            fflush (flow_dump_file);
  1566.          });
  1567.  
  1568.   /* If -opt, try combining insns through substitution.  */
  1569.  
  1570.   if (optimize)
  1571.     TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
  1572.  
  1573.   /* Dump rtl code after insn combination.  */
  1574.  
  1575.   if (combine_dump)
  1576.     TIMEVAR (dump_time,
  1577.          {
  1578.            fprintf (combine_dump_file, "\n;; Function %s\n\n",
  1579.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1580.            dump_combine_stats (combine_dump_file);
  1581.            print_rtl (combine_dump_file, insns);
  1582.            fflush (combine_dump_file);
  1583.          });
  1584.  
  1585.   /* Unless we did stupid register allocation,
  1586.      allocate pseudo-regs that are used only within 1 basic block.  */
  1587.  
  1588.   if (!obey_regdecls)
  1589.     TIMEVAR (local_alloc_time,
  1590.          {
  1591.            regclass (insns, max_reg_num ());
  1592.            local_alloc ();
  1593.          });
  1594.  
  1595.   /* Dump rtl code after allocating regs within basic blocks.  */
  1596.  
  1597.   if (local_reg_dump)
  1598.     TIMEVAR (dump_time,
  1599.          {
  1600.            fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
  1601.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1602.            dump_flow_info (local_reg_dump_file);
  1603.            dump_local_alloc (local_reg_dump_file);
  1604.            print_rtl (local_reg_dump_file, insns);
  1605.            fflush (local_reg_dump_file);
  1606.          });
  1607.  
  1608.   if (global_reg_dump)
  1609.     TIMEVAR (dump_time,
  1610.          fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
  1611.               IDENTIFIER_POINTER (DECL_NAME (decl))));
  1612.  
  1613.   /* Unless we did stupid register allocation,
  1614.      allocate remaining pseudo-regs, then do the reload pass
  1615.      fixing up any insns that are invalid.  */
  1616.  
  1617.   TIMEVAR (global_alloc_time,
  1618.        {
  1619.          if (!obey_regdecls)
  1620.            global_alloc (global_reg_dump ? global_reg_dump_file : 0);
  1621.          else
  1622.            reload (insns, 0,
  1623.                global_reg_dump ? global_reg_dump_file : 0);
  1624.        });
  1625.  
  1626.   if (global_reg_dump)
  1627.     TIMEVAR (dump_time,
  1628.          {
  1629.            dump_global_regs (global_reg_dump_file);
  1630.            print_rtl (global_reg_dump_file, insns);
  1631.            fflush (global_reg_dump_file);
  1632.          });
  1633.  
  1634.   rtx_equal_function_value_matters = 1;
  1635.   reload_completed = 1;
  1636.  
  1637.   /* One more attempt to remove jumps to .+1
  1638.      left by dead-store-elimination.
  1639.      Also do cross-jumping this time
  1640.      and delete no-op move insns.  */
  1641.  
  1642.   if (optimize)
  1643.     {
  1644.       TIMEVAR (jump_time, jump_optimize (insns, 1, 1));
  1645.     }
  1646.  
  1647.   /* Dump rtl code after jump, if we are doing that.  */
  1648.  
  1649.   if (jump2_opt_dump)
  1650.     TIMEVAR (dump_time,
  1651.          {
  1652.            fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
  1653.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1654.            print_rtl (jump2_opt_dump_file, insns);
  1655.            fflush (jump2_opt_dump_file);
  1656.          });
  1657.  
  1658.   /* If a scheduling pass for delayed branches is to be done,
  1659.      call the scheduling code. */
  1660.  
  1661. #ifdef HAVE_DELAYED_BRANCH
  1662.   if (optimize && flag_delayed_branch)
  1663.     {
  1664.       TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
  1665.       if (dbr_sched_dump)
  1666.     {
  1667.       TIMEVAR (dump_time,
  1668.          {
  1669.            fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
  1670.                 IDENTIFIER_POINTER (DECL_NAME (decl)));
  1671.            print_rtl (dbr_sched_dump_file, insns);
  1672.            fflush (dbr_sched_dump_file);
  1673.          });
  1674.     }
  1675.     }
  1676. #endif
  1677.  
  1678.   /* Now turn the rtl into assembler code.  */
  1679.  
  1680.   TIMEVAR (final_time,
  1681.        {
  1682.          assemble_function (decl);
  1683.          final_start_function (insns, asm_out_file,
  1684.                    write_symbols, optimize);
  1685.          final (insns, asm_out_file,
  1686.             write_symbols, optimize, 0);
  1687.          final_end_function (insns, asm_out_file,
  1688.                  write_symbols, optimize);
  1689.          fflush (asm_out_file);
  1690.        });
  1691.  
  1692.   /* Write GDB symbols if requested */
  1693.  
  1694.   if (write_symbols == GDB_DEBUG)
  1695.     {
  1696.       TIMEVAR (symout_time,
  1697.            {
  1698.          symout_types (get_permanent_types ());
  1699.          symout_types (get_temporary_types ());
  1700.  
  1701.          DECL_BLOCK_SYMTAB_ADDRESS (decl)
  1702.            = symout_function (DECL_INITIAL (decl),
  1703.                       DECL_ARGUMENTS (decl), 0);
  1704.          symout_function_end ();
  1705.            });
  1706.     }
  1707.   else
  1708.     get_temporary_types ();
  1709.  
  1710.   /* Write DBX symbols if requested */
  1711.  
  1712. #ifdef DBX_DEBUGGING_INFO
  1713.   if (write_symbols == DBX_DEBUG)
  1714.     TIMEVAR (symout_time, dbxout_function (decl));
  1715. #endif
  1716.  
  1717.  exit_rest_of_compilation:
  1718.  
  1719.   rtx_equal_function_value_matters = 0;
  1720.   reload_completed = 0;
  1721.  
  1722.   /* Clear out the real_constant_chain before some of the rtx's
  1723.      it runs through become garbage.  */
  1724.  
  1725.   clear_const_double_mem ();
  1726.  
  1727.   /* The parsing time is all the time spent in yyparse
  1728.      *except* what is spent in this function.  */
  1729.  
  1730.   parse_time -= gettime () - start_time;
  1731. }
  1732.  
  1733. /* Entry point of cc1.  Decode command args, then call compile_file.
  1734.    Exit code is 35 if can't open files, 34 if fatal error,
  1735.    33 if had nonfatal errors, else success.  */
  1736.  
  1737. int
  1738. main (argc, argv, envp)
  1739.      int argc;
  1740.      char **argv;
  1741.      char **envp;
  1742. {
  1743.   register int i;
  1744.   char *filename = 0;
  1745.   int print_mem_flag = 0;
  1746.   char *p;
  1747.  
  1748.   /* save in case md file wants to emit args as a comment.  */
  1749.   save_argc = argc;
  1750.   save_argv = argv;
  1751.  
  1752.   p = argv[0] + strlen (argv[0]);
  1753.   while (p != argv[0] && p[-1] != '/') --p;
  1754.   progname = p;
  1755.  
  1756. #ifdef RLIMIT_STACK
  1757.   /* Get rid of any avoidable limit on stack size.  */
  1758.   {
  1759.     struct rlimit rlim;
  1760.  
  1761.     /* Set the stack limit huge so that alloca does not fail. */
  1762.     getrlimit (RLIMIT_STACK, &rlim);
  1763.     rlim.rlim_cur = rlim.rlim_max;
  1764.     setrlimit (RLIMIT_STACK, &rlim);
  1765.   }
  1766. #endif /* RLIMIT_STACK */
  1767.  
  1768.   signal (SIGFPE, float_signal);
  1769.  
  1770.   signal (SIGPIPE, pipe_closed);
  1771.  
  1772.   /* Initialize whether `char' is signed.  */
  1773.   flag_signed_char = DEFAULT_SIGNED_CHAR;
  1774. #ifdef DEFAULT_SHORT_ENUMS
  1775.   /* Initialize how much space enums occupy, by default.  */
  1776.   flag_short_enums = DEFAULT_SHORT_ENUMS;
  1777. #endif
  1778.  
  1779.   /* This is zeroed by -O.  */
  1780.   obey_regdecls = 1;
  1781.  
  1782.   /* Initialize register usage now so switches may override.  */
  1783.   init_reg_sets ();
  1784.  
  1785.   target_flags = 0;
  1786.   set_target_switch ("");
  1787.  
  1788.   for (i = 1; i < argc; i++)
  1789.     if (argv[i][0] == '-' && argv[i][1] != 0)
  1790.       {
  1791.     register char *str = argv[i] + 1;
  1792.     if (str[0] == 'Y')
  1793.       str++;
  1794.  
  1795.     if (str[0] == 'm')
  1796.       set_target_switch (&str[1]);
  1797.     else if (!strcmp (str, "dumpbase"))
  1798.       {
  1799.         dump_base_name = argv[++i];
  1800.       }
  1801.     else if (str[0] == 'd')
  1802.       {
  1803.         register char *p = &str[1];
  1804.         while (*p)
  1805.           switch (*p++)
  1806.         {
  1807.         case 'c':
  1808.           combine_dump = 1;
  1809.           break;
  1810.         case 'd':
  1811.           dbr_sched_dump = 1;
  1812.           break;
  1813.         case 'f':
  1814.           flow_dump = 1;
  1815.           break;
  1816.         case 'g':
  1817.           global_reg_dump = 1;
  1818.           break;
  1819.         case 'j':
  1820.           jump_opt_dump = 1;
  1821.           break;
  1822.         case 'J':
  1823.           jump2_opt_dump = 1;
  1824.           break;
  1825.         case 'l':
  1826.           local_reg_dump = 1;
  1827.           break;
  1828.         case 'L':
  1829.           loop_dump = 1;
  1830.           break;
  1831.         case 'm':
  1832.           print_mem_flag = 1;
  1833.           break;
  1834.         case 'r':
  1835.           rtl_dump = 1;
  1836.           break;
  1837.         case 's':
  1838.           cse_dump = 1;
  1839.           break;
  1840.         case 'y':
  1841.           yydebug = 1;
  1842.           break;
  1843.         }
  1844.       }
  1845.     else if (str[0] == 'f')
  1846.       {
  1847.         int j;
  1848.         register char *p = &str[1];
  1849.         int found = 0;
  1850.  
  1851.         /* Some kind of -f option.
  1852.            P's value is the option sans `-f'.
  1853.            Search for it in the table of options.  */
  1854.  
  1855.         for (j = 0;
  1856.          !found && j < sizeof (f_options) / sizeof (f_options[0]);
  1857.          j++)
  1858.           {
  1859.         if (!strcmp (p, f_options[j].string))
  1860.           {
  1861.             *f_options[j].variable = f_options[j].on_value;
  1862.             /* A goto here would be cleaner,
  1863.                but breaks the vax pcc.  */
  1864.             found = 1;
  1865.           }
  1866.         if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
  1867.             && ! strcmp (p+3, f_options[j].string))
  1868.           {
  1869.             *f_options[j].variable = ! f_options[j].on_value;
  1870.             found = 1;
  1871.           }
  1872.           }
  1873.  
  1874.         if (found)
  1875.           ;
  1876.         else if (!strncmp (p, "fixed-", 6))
  1877.           fix_register (&p[6], 1, 1);
  1878.         else if (!strncmp (p, "call-used-", 10))
  1879.           fix_register (&p[10], 0, 1);
  1880.         else if (!strncmp (p, "call-saved-", 11))
  1881.           fix_register (&p[11], 0, 0);
  1882.         else if (! lang_decode_option (argv[i]))
  1883.           error ("Invalid option `%s'", argv[i]);
  1884.       }
  1885.     else if (!strcmp (str, "noreg"))
  1886.       ;
  1887.     else if (!strcmp (str, "opt"))
  1888.       optimize = 1, obey_regdecls = 0;
  1889.     else if (!strcmp (str, "O"))
  1890.       optimize = 1, obey_regdecls = 0;
  1891.     else if (!strcmp (str, "pedantic"))
  1892.       pedantic = 1;
  1893.     else if (lang_decode_option (argv[i]))
  1894.       ;
  1895.     else if (!strcmp (str, "quiet"))
  1896.       quiet_flag = 1;
  1897.     else if (!strcmp (str, "version"))
  1898.       {
  1899.         extern char *version_string, *language_string;
  1900.         fprintf (stderr, "%s version %s", language_string, version_string);
  1901. #ifdef TARGET_VERSION
  1902.         TARGET_VERSION;
  1903. #endif
  1904. #ifdef __GNUC__
  1905. #ifndef __VERSION__
  1906. #define __VERSION__ "[unknown]"
  1907. #endif
  1908.         fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
  1909. #else
  1910.         fprintf (stderr, " compiled by CC.\n");
  1911. #endif
  1912.         print_target_switch_defaults ();
  1913.       }
  1914.     else if (!strcmp (str, "w"))
  1915.       inhibit_warnings = 1;
  1916.     else if (!strcmp (str, "W"))
  1917.       extra_warnings = 1;
  1918.     else if (!strcmp (str, "Wunused"))
  1919.       warn_unused = 1;
  1920.     else if (!strcmp (str, "Wshadow"))
  1921.       warn_shadow = 1;
  1922.     else if (!strcmp (str, "Wswitch"))
  1923.       warn_switch = 1;
  1924.     else if (!strncmp (str, "Wid-clash-", 10))
  1925.       {
  1926.         char *endp = str + 10;
  1927.  
  1928.         while (*endp)
  1929.           {
  1930.         if (*endp >= '0' && *endp <= '9')
  1931.           endp++;
  1932.         else
  1933.           error ("Invalid option `%s'", argv[i]);
  1934.           }
  1935.         warn_id_clash = 1;
  1936.         id_clash_len = atoi (str + 10);
  1937.       }
  1938.     else if (!strcmp (str, "p"))
  1939.       profile_flag = 1;
  1940.     else if (!strcmp (str, "a"))
  1941.       {
  1942. #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
  1943.         warning ("`-a' option (basic block profile) not supported");
  1944. #else
  1945.         profile_block_flag = 1;
  1946. #endif
  1947.       }
  1948.     else if (!strcmp (str, "gg"))
  1949.       write_symbols = GDB_DEBUG;
  1950. #ifdef DBX_DEBUGGING_INFO
  1951.     else if (!strcmp (str, "g0"))
  1952.       write_symbols = DBX_DEBUG;
  1953.     else if (!strcmp (str, "G0"))
  1954.       write_symbols = DBX_DEBUG;
  1955.     else if (!strcmp (str, "g"))
  1956.       {
  1957.         write_symbols = DBX_DEBUG;
  1958.         use_gdb_dbx_extensions = 1;
  1959.       }
  1960.     else if (!strcmp (str, "G"))
  1961.       {
  1962.         write_symbols = DBX_DEBUG;
  1963.         use_gdb_dbx_extensions = 1;
  1964.       }
  1965. #endif
  1966. #ifdef SDB_DEBUGGING_INFO
  1967.     else if (!strcmp (str, "g"))
  1968.       write_symbols = SDB_DEBUG;
  1969.     else if (!strcmp (str, "G"))
  1970.       write_symbols = SDB_DEBUG;
  1971.     else if (!strcmp (str, "g0"))
  1972.       write_symbols = SDB_DEBUG;
  1973.     else if (!strcmp (str, "G0"))
  1974.       write_symbols = SDB_DEBUG;
  1975. #endif
  1976.     else if (!strcmp (str, "symout"))
  1977.       {
  1978.         if (write_symbols == NO_DEBUG)
  1979.           write_symbols = GDB_DEBUG;
  1980.         sym_file_name = argv[++i];
  1981.       }
  1982.     else if (!strcmp (str, "o"))
  1983.       {
  1984.         asm_file_name = argv[++i];
  1985.       }
  1986.     else
  1987.       error ("Invalid option `%s'", argv[i]);
  1988.       }
  1989.     else
  1990.       filename = argv[i];
  1991.  
  1992. #ifdef OVERRIDE_OPTIONS
  1993.   /* Some machines may reject certain combinations of options.  */
  1994.   OVERRIDE_OPTIONS;
  1995. #endif
  1996.  
  1997.   /* Now that register usage is specified, convert it to HARD_REG_SETs.  */
  1998.   init_reg_sets_1 ();
  1999.  
  2000.   compile_file (filename);
  2001.  
  2002. #ifndef USG
  2003. #ifndef VMS
  2004.   if (print_mem_flag)
  2005.     {
  2006.       extern char **environ;
  2007.       char *lim = (char *) sbrk (0);
  2008.  
  2009.       fprintf (stderr, "Data size %d.\n",
  2010.            (int) lim - (int) &environ);
  2011.       fflush (stderr);
  2012.  
  2013.       system ("ps v");
  2014.     }
  2015. #endif /* not VMS */
  2016. #endif /* not USG */
  2017.  
  2018.   if (errorcount)
  2019.     exit (FATAL_EXIT_CODE);
  2020.   if (sorrycount)
  2021.     exit (FATAL_EXIT_CODE);
  2022.   exit (SUCCESS_EXIT_CODE);
  2023.   return 34;
  2024. }
  2025.  
  2026. /* Decode -m switches.  */
  2027.  
  2028. /* Here is a table, controlled by the tm-...h file, listing each -m switch
  2029.    and which bits in `target_switches' it should set or clear.
  2030.    If VALUE is positive, it is bits to set.
  2031.    If VALUE is negative, -VALUE is bits to clear.
  2032.    (The sign bit is not used so there is no confusion.)  */
  2033.  
  2034. struct {char *name; int value;} target_switches []
  2035.   = TARGET_SWITCHES;
  2036.  
  2037. /* Decode the switch -mNAME.  */
  2038.  
  2039. void
  2040. set_target_switch (name)
  2041.      char *name;
  2042. {
  2043.   register int j;
  2044.   for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
  2045.     if (!strcmp (target_switches[j].name, name))
  2046.       {
  2047.     if (target_switches[j].value < 0)
  2048.       target_flags &= ~-target_switches[j].value;
  2049.     else
  2050.       target_flags |= target_switches[j].value;
  2051.     return;
  2052.       }
  2053.   error ("Invalid option `%s'", name);
  2054. }
  2055.  
  2056. /* Print default target switches for -version.  */
  2057.  
  2058. void
  2059. print_target_switch_defaults ()
  2060. {
  2061.   register int j;
  2062.   register int mask = TARGET_DEFAULT;
  2063.   fprintf (stderr, "default target switches:");
  2064.   for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
  2065.     if (target_switches[j].name[0] != '\0'
  2066.     && target_switches[j].value > 0
  2067.     && (target_switches[j].value & mask) == target_switches[j].value)
  2068.  
  2069.       fprintf (stderr, " -m%s", target_switches[j].name);
  2070.  
  2071.   fprintf (stderr, "\n");
  2072. }
  2073.